package com.tengju.data.infrastructure.repository.convert;

import com.tengju.data.domain.model.activity.ActivityDetail;
import com.tengju.data.domain.model.activity.ActivityId;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.DealerMarketingCalendarDO;
import com.tengju.user.domain.shared.DateUtil;

import java.time.LocalDate;

/**
 * @author: 大木
 * @date: 2021/10/13 8:31 下午
 */
public class ActivityTargetAnalysisConvert {

    public static ActivityDetail convert(DealerMarketingCalendarDO dealerMarketingCalendarDO) {
        if (dealerMarketingCalendarDO == null) {
            return null;
        }
        LocalDate startTime = DateUtil.dateToLocalDate(dealerMarketingCalendarDO.getStartTime());
        LocalDate endTime = DateUtil.dateToLocalDate(dealerMarketingCalendarDO.getEndTime());
        return new ActivityDetail(
                new ActivityId(dealerMarketingCalendarDO.getId()),
                dealerMarketingCalendarDO.getTitle(),
                startTime, endTime);
    }

}
